<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Game
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>
<?php if ($this->paginator->getTotalItemCount()): ?>
  
  <?php if ($this->display_style == 'narrow'): ?>
    <ul class='games_list'>
      <?php foreach ($this->paginator as $game): ?>     
        <li>
          <?php if ($this->showphoto): ?>
            <div class="game_photo">
              <?php echo $this->htmlLink($game->getHref(), $this->itemPhoto($game, 'thumb.icon'));?>
            </div>
          <?php endif; ?>
          <div class="game_content">
            <div class="game_title">
              <?php echo $this->htmlLink($game->getHref(), $this->radcodes()->text()->truncate($game->getTitle(), 24))?>
            </div>
            <?php if ($this->showdescription && $game->getDescription()): ?>
              <div class="game_description">
                <?php echo $this->partial('index/_description.tpl', 'game', array('game' => $game))?>
              </div>
            <?php endif; ?>
            <?php if ($this->showdetails): ?>
              <div class="game_details">
                <?php echo $this->htmlLink($game->getCategory()->getHref(), $this->translate($game->getCategory()->getTitle())); ?>
              </div>
            <?php endif; ?>             
            <?php if ($this->showmeta): ?>
              <div class="game_meta">
                <?php 
                  $meta_options = array('game' => $game);
                  if ($this->order == 'mostcommented') {
                    $meta_options['show_comments'] = true;
                  }
                  else if ($this->order == 'mostviewed') {
                    $meta_options['show_views'] = true;
                  }
                  else if ($this->order == 'mostliked') {
                    $meta_options['show_likes'] = true;
                  }
                  else if ($this->order == 'mostfavorited') {
                    $meta_options['show_favorites'] = true;
                  }
                  else if ($this->order == 'lastupdated') {
                    $meta_options['show_updated'] = true;
                  }
                  else {
                    $meta_options['show_created'] = true;
                  }
                ?>
                <?php echo $this->partial('index/_meta.tpl', 'game', $meta_options)?>
              </div>
            <?php endif; ?>
          </div>
        </li>
      <?php endforeach; ?>  
    </ul>

  <?php else: ?>
    <ul class="games_blocks">
	    <?php foreach( $this->paginator as $game ): ?>      
	      <li>
            <?php if ($this->showphoto): ?>
              <div class="game_photo">
                <?php echo $this->htmlLink($game->getHref(), $this->itemPhoto($game, 'thumb.normal'));?>
              </div>
            <?php endif; ?>
            <div class="game_content">
              <div class="game_title">
                <?php echo $this->partial('index/_title.tpl', 'game', array('game' => $game, 'max_title_length' => 28))?>
              </div>
              <?php if ($this->showdetails): ?>
                <div class="game_details">
                  <?php echo $this->htmlLink($game->getCategory()->getHref(), $this->translate($game->getCategory()->getTitle())); ?>
                </div>
              <?php endif; ?>    
              <?php if ($this->showmeta): ?>
                <div class="game_meta">
                  <?php 
                    $meta_options = array('game' => $game);
                    if ($this->order == 'mostcommented') {
                      $meta_options['show_comments'] = true;
                    }
                    else if ($this->order == 'mostviewed') {
                      $meta_options['show_views'] = true;
                    }
                    else if ($this->order == 'mostliked') {
                      $meta_options['show_likes'] = true;
                    }
                    else if ($this->order == 'mostfavorited') {
                      $meta_options['show_favorites'] = true;
                    }
                    else if ($this->order == 'lastupdated') {
                      $meta_options['show_updated'] = true;
                    }
                    else {
                      $meta_options['show_created'] = true;
                    }
                  ?>
                  <?php echo $this->partial('index/_meta.tpl', 'game', $meta_options)?>
                </div>
              <?php endif; ?>
            </div>
            <?php if ($game->leaderboard_enabled): ?>
              <div class="game_icons">
                <span class="game_icon_leaderboard<?php if (!$game->leaderboard_enabled) echo "_off"?>"></span>
              </div>
            <?php endif;?>
	      </li>
	    <?php endforeach; ?>
    </ul>
  <?php endif;?>
<?php else: ?>
  <div class="tip">
    <span>
      <?php echo $this->translate('There are no related games.');?>
    </span>
  </div>  
<?php endif; ?>